<template>
    <div class="z-tab-bar max-w-screen-sm cursor-pointer select-none">
        <div
            v-for="(item,index) in tabList"
            :key="index"
            :class="selectIndex === index ? 'select-index' : ''"
            @click="toChange(index)"
            style="position: relative;flex: 1;"
        >
            <van-badge dot v-if="item.id === 1 || item.id === 2 || item.id === 5"><span>{{ item.name }}</span></van-badge>
            <van-badge v-if="item.id === 4">{{ item.name }}</van-badge>
            <!-- <div class="center-big" v-if="item.id === 3">
                <van-icon name="paid" />
            </div> -->
        </div>
    </div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
defineProps({
    tabList: {
        type: Array as () => Array<{ id: number, name: string }>,
        default: () => [{ id: 1, name: '首页' }, { id: 2, name: '朋友' }, { id: 3, name: '开始' }, { id: 4, name: '消息' }, { id: 5, name: '我的' }]
    }
})
const emit = defineEmits(['change'])
let selectIndex = ref<Number>(0)
const toChange = (index: Number) => {
    if (index === 2) return;
    selectIndex.value = index;
    emit('change',index)
}
</script>
<style lang="scss">
.z-tab-bar {
    position: fixed;
    bottom: 0;
    height: 30px;
    display: flex;
    width: 100%;
    justify-content: space-around;
    text-align: center;
    background: transparent;
    color: white;
    .center-big {
        width: 50px;
        position: absolute;
        bottom: 0px;
        left: 50%;
        transform: translate(-50%);
        height: 50px;
        background-color: #ffd01e;
        color: white;
        font-size: 28px;
        line-height: 50px;
        border-radius: 12px;
    }
    .select-index {
        color: red;
    }
    .van-badge {
        border: none;
    }
}
</style>
